<!DOCTYPE html>
<html lang="en-US">
  <head>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
    <script crossorigin="anonymous" src="/test-harness.js"></script>
    <script crossorigin="anonymous" src="/test-page-object.js"></script>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
  </head>
  <body>
    <main id="webchat"></main>
    <script>
      run(async function () {
        const store = testHelpers.createStore();
        const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
        const baseProps = { directLine, store };
        const webChatElement = document.getElementById('webchat');

        WebChat.renderWebChat(baseProps, webChatElement);

        await pageConditions.uiConnected();

        await pageObjects.sendMessageViaSendBox('carousel', { waitForSend: true });
        await pageObjects.sendMessageViaSendBox('layout double', { waitForSend: true });
        await pageObjects.sendMessageViaSendBox('layout carousel', { waitForSend: true });
        await pageObjects.sendMessageViaSendBox('Hello world', { waitForSend: true });
        await pageObjects.sendMessageViaSendBox('receiptcard', { waitForSend: true });
        await pageConditions.minNumActivitiesShown(10);
        await pageConditions.scrollToBottomCompleted();

        const invalidElements = [].filter.call(
          document.querySelectorAll('[aria-roledescription]'),
          element => !element.getAttribute('role')
        );

        invalidElements.length &&
          console.error('Elements with "aria-roledescription" attribute but not "role" attribute:', {
            invalidElements
          });

        expect(invalidElements).toHaveProperty('length', 0);
      });
    </script>
  </body>
</html>
